<?php

require 'Model.php';

class IndexModel extends Model{
   function getTypeList(){
       $sql="SELECT * from videotype";
       $data=$this->conn->query($sql);
       return $data;
   }


   function getRecentList(){
       $sql="SELECT * FROM videos ORDER BY uploadtime DESC LIMIT 3";
       $datarecentervideo=$this->conn->query($sql);
       return $datarecentervideo;
}
    function getIndexVideoFromType($tid){
        $sql="SELECT * FROM videos  WHERE tid=$tid ORDER BY uploadtime DESC LIMIT 3";
        $data=$this->conn->query($sql);
        return $data;
    }
    function getVideoFromType($tid){
        $sql="SELECT * FROM videos  WHERE tid=$tid";
        $data=$this->conn->query($sql);
        return $data;
    }
    function getHotList(){
        $sql="SELECT * FROM videos ORDER BY hittimes DESC LIMIT 4";
        $datahotvideo=$this->conn->query($sql);
        return $datahotvideo;

    }
    function searchVideo($search){
        $sql="select * from videos where videoname like '%$search%'";
        $data=$this->conn->query($sql);
        return $data;

    }
    function getVideoAbout($vid){
        $sql="SELECT * FROM videos  WHERE vid=$vid";
        $data=$this->conn->query($sql);
        return $data;
    }
    function userLogin($username,$password){

        $sql = "select * from users where uname='$username'and password='$password'";
        $result=$this->conn->query($sql);
        return $result;
    }

}
?>